﻿using System;

namespace Spectro.Cards.Actions.Fire
{
    /// <summary>
    /// Action for FireBolt
    /// </summary>
    public class FireBolt : IFireAction
    {
        public FireBolt()
        {
            Damage = 5;
        }

        public int Damage { get; set; }

        public Warior Warior { get; set; }

        public void Execute(Gamer defender, Gamer attacker)
        {
            for (int index= 0; index < defender.Wariors.Length; index++)
            {
                var warior = defender.Wariors[index];
                if (warior != null)
                {
                    if (warior.IsCanExecuteEction(this, attacker, defender))
                    {
                        warior.Health = warior.Health - this.Damage;
                        if (warior.Health <= 0)
                        {
                            warior = warior.Die(attacker, defender);
                        }
                    }
                }
            }
        }
    }
}
